import java.util.*;

/**
 * 对自定义类型排序的时候，需要实现comparable接口，重写compareTo()方法
 *
 */


class Student implements Comparable<Student> {
    public String name;
    public String grade;
    public double score;

    public Student(String name, String grade, double score) {
        this.name = name;
        this.grade = grade;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name=" + name +
                ", grade=" + grade +
                ", score=" + score +
                '}';
    }


    @Override
    public int compareTo(Student o) {
        return (int)(this.score - o.score);
    }
}

public class homeWork {

    /**
     * 题目描述：将学生对象（Student->name/grade/score）放在List中
     * 输出打印
     * @param args
     */
    public static void main1(String[] args) {
        //可自定义泛型类型
        List<Student> list = new ArrayList<>();
        list.add(new Student("fxt", "2001", 95));
        list.add(new Student("fx", "2002", 100));
        list.add(new Student("fzq", "2003", 99));

        //按score排序,Student类实现comparable接口，重写CompareTo()方法
        Collections.sort(list);

        System.out.println(list);

    }


    /**
     * 题目描述：List中存放整型数据，要求使用Collections.sort对List进行排序
     */
    public static void main2(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();

        list.add(34);
        list.add(56);
        list.add(23);
        list.add(68);
        System.out.println(list);
        Collections.sort(list);
        System.out.println(list);

    }


    /**
     * 题目描述：( CVTE 面试题)
     * 删除第一个字符串当中出现的第二个字符串中的字符
     * String str1 = "welcome to bit";
     * String str2 = "come";
     * 输出结果：wl t bit
     *
     * @param args
     */
    public static void main3(String[] args) {
        String str1 = "welcome to bit";
        String str2 = "come";
        List<Character> list = new ArrayList<>();

        for (int i = 0; i < str1.length(); i++) {
            char ch1 = str1.charAt(i);
            if(!str2.contains(ch1+"")){
                list.add(ch1);
            }
        }
        //System.out.println(list);
        for (int i = 0; i < list.size(); i++) {
            System.out.print(list.get(i));
        }

    }




}
